    /****************************************** 
  	 初始化数据
  	*******************************************/
  
  //echart   
  var bbtChart;
  var gridX = 35;
  var gridY = 10;
  var gridX2 = 10;
  var gridY2 = 30;
  	
  //X轴
  var currentDateStr;	
  var xAxisDateArray;
  var xTickLength;
  var xAxisLabelMargin = -20;
  
  //Y轴 
  var yAxisMinTemperature;
  var yAxisMaxTemperature;
	
  var bbtTitle = '基础体温';
  var bgColor = '背景颜色';
  var yjqTitle;
  var lpqTitle;
  var plqTitle;
  var htqTitle;
	
  var bbtDataArray = new Array();
  var polishedBBTDataArray = new Array();
  var bgColorDataArray = new Array();
  var yAxisInterval;
  var yAxisSplitNumber;

  //背景色
  var yjqBackgroundColor = 'rgba(255,232,232,0.5)';
  var lpqBackgroundColor = 'rgba(198,226,255,0.5)';
  var plqBackgroundColor = 'rgba(232,247,225,0.5)';
  var htqBackgroundColor = 'rgba(255,250,205,0.5)';
  var unknownBackgroundColor = 'rgba(255,255,255,0.5)';
 
    function initBBTChartData(){
    	initOrientation();	
    	initBBTChartZone();        	
    	initShowTip();	

		initXAxisData();
		initXTickLength();	
		initYAxisData();
		initYAxisDiv();
		
		initBgColorData();
    }
    
    function initOrientation(){	  	
	  	if(isPortrait())	  		
	  		setPortraitData(); 		
	  	else		
  			setLandscapeData();   			  		
    }
    
    function initBBTChartZone(){
		setBBTChartFixZone(bbtChartWidth, bbtChartHeight);
		setBBTChartScrollZone(bbtChartWidth, bbtChartHeight);
    	setBBTChartZone(bbtChartWidth, bbtChartHeight);    
    }
    
    function getScreenWidth(){
    	return window.innerWidth;
    }
    
    function getScreenHeight(){
    	if(isIphone())
    		return window.innerHeight + 49;
    	else
    		return window.innerHeight;
    }
    
    //作为iphone的横屏时,高度返回：补偿下部控件栏高度为49的workaround
    function isIphone(){
    	var u = navigator.userAgent;
    	if(u.indexOf('iPhone') > -1)
    		return true;
    	else
    		return false;
    }
    
    function setBBTChartFixZone(bbtChartWidth, bbtChartHeight){
    	document.getElementById('div_fix_zone').style.width = bbtChartWidth + "px";
    	document.getElementById('div_fix_zone').style.height = bbtChartHeight + "px";
    }
    
    function setBBTChartScrollZone(bbtChartWidth, bbtChartHeight){
    	document.getElementById('div_scroll_zone').style.width = bbtChartWidth + "px";
    	document.getElementById('div_scroll_zone').style.height = bbtChartHeight + "px";
    }
    
    function setBBTChartZone(bbtChartWidth, bbtChartHeight){   	
    	document.getElementById('bbtLineChart').style.width = bbtChartWidth * SCREEN_WIDTH_SCALE + "px";
    	document.getElementById('bbtLineChart').style.height = bbtChartHeight + "px";    
    	document.getElementById('bbtLineChart').style.marginLeft = -(Math.round((SCREEN_WIDTH_SCALE - 1) / 2) * bbtChartWidth)+ "px";	
    }
    
    function initShowTip(){
    	if(portraitOrLandscape == "portrait")
  			showTip = false;
  		else
  			showTip = true;
  	}
  
    //x轴数据初始化
    function initXAxisData(){   	
		initXAxisDateArray();			
		getFirstLastXAxisLabelDate(xAxisDateArray);			
    }
    
    function initXAxisDateArray(){
    	currentDateStr = getCurrentDateStr();
		
		if(portraitOrLandscape == "landscape")	
			xAxisDateArray = getRoundDate(currentDateStr, landscapeBeforeShowDaysNum, landscapeAfterShowDaysNum);
		else
			xAxisDateArray = getRoundDate(currentDateStr, portraitBeforeShowDaysNum, portraitAfterShowDaysNum);
    }

    function getFirstLastXAxisLabelDate(xAxisDateArray){    	
		preSwipeFirstXAxisDate = xAxisDateArray[0];	 	
		preSwipeLastXAxisDate = xAxisDateArray[xAxisDateArray.length - 1];
    }
    
    function initXTickLength(){
	  	var xTickTotal = webviewWidth - gridX - gridX2;
	  	xTickLength = xTickTotal / showDaysTotalNum;
   }
    
    //y轴数据初始化
    function initYAxisData(){    			
	  	setYAxisTemperatureScope();
	  	setPeriodTitle();
	    setYAxisSplit();
	    setYAxisData();
    }
    
    function setYAxisTemperatureScope(){
    	yAxisMinTemperature = 35;
	  	yAxisMaxTemperature = 38;
    }
    
    function setPeriodTitle(){        	
	    yjqTitle = '月经期';
	    lpqTitle = '卵泡期';
	    plqTitle = '排卵期';
	    htqTitle = '黄体期';
	    unknownTitle = '暂未知';
	}
    
    function setYAxisSplit(){
    	if(portraitOrLandscape == "portrait")
    		yAxisInterval = 5;
    		
    	if(portraitOrLandscape == "landscape")
    		yAxisInterval = 2;
    		
	    yAxisSplitNumber = yAxisInterval * (yAxisMaxTemperature - yAxisMinTemperature);
    }
    
    function setYAxisData(){
    	for(var i = 0; i < xAxisDateArray.length; i++){
    		bbtDataArray[i] = customerDateTemperatureMap.get(xAxisDateArray[i]);
    		var polishedTemperature = customerDatePolishedTemperatureMap.get(xAxisDateArray[i]);

    		if(bbtDataArray[i] != "-")
    			polishedBBTDataArray.push({value: bbtDataArray[i], symbol: 'circle', symbolSize: 4});
    		else if(bbtDataArray[i] == "-" && polishedTemperature != "-")
    			polishedBBTDataArray.push({ value: polishedTemperature, symbol: 'none'});
            else
            	polishedBBTDataArray.push("-");
    	}
    }

    function getPreviousValidTemperature(index){
      	if(index == 0)
      		return 0;

      	var validData = "-";
      	for(var i = index - 1; i >= 0; i--){
      		if(bbtDataArray[i] != "-"){
      			validData = bbtDataArray[i];
      			break;
      		}
      	}

      	if(i == -1 && validData == "-")
      		return 0;

      	return validData;
    }

    function getFirstValidTemperatureDate(){
    	var dateStr = "-";

    	for(var i = 0; i < xAxisDateArray.length; i++){
    		if(customerDateTemperatureMap.get(xAxisDateArray[i]) != "-"){
    			dateStr = xAxisDateArray[i];
    			break;
    		}
    	}

    	return dateStr;
    }

    //目前只支持2等份/5等份的Y轴悬浮刻度
    function initYAxisDiv(){
    	
    
    	var yAxisDivStr = "";
    	var tempYAxisTickValue = 1/yAxisInterval;
    	var yAxisTickValue = tempYAxisTickValue.toFixed(1);
    	
    	var yAxisLength = bbtChartHeight - gridY - gridY2;
    	var yAxisTickLength = yAxisLength / yAxisSplitNumber;

    	document.getElementById('bbtLineChartYAxisTable').style.height = yAxisLength + "px";
    	
    	var preDivStr = '<tr> <td style="vertical-align:top;height:'+yAxisTickLength+';">';
    	var postDivStr = '</td> </tr>';

    	for(var i = yAxisMaxTemperature.toFixed(1); ; ){
    	
    		if(parseInt(i) == i)
    			yAxisDivStr += preDivStr + i + postDivStr;  
    		else
    			yAxisDivStr += preDivStr + "." + (i*10)%10 + postDivStr;  
    			 			
    		i = i - yAxisTickValue;	
    		i = i.toFixed(1);   
    		
    		if(i*10 == yAxisMinTemperature*10) 		
    		{
    			yAxisDivStr += i;
    			break;
    		}  		
    	}
	    	    	      	
    	document.getElementById('bbtLineChartYAxis').style.marginTop = gridY + "px";
    	document.getElementById('bbtLineChartYAxis').style.marginBottom = gridY2 + "px";
    	document.getElementById('bbtLineChartYAxis').style.height = yAxisLength + "px";
    	document.getElementById('bbtLineChartYAxisTable').innerHTML = yAxisDivStr; 
    }     
    
    
    function initBgColorData(){
    	for(var i = 0; i < xAxisDateArray.length; i++)
    		bgColorDataArray[i] = yAxisMaxTemperature;
    }
    
